package com.pkche.core.base.crud;

import java.util.List;

import com.pkche.core.base.common.Constants;

/**
 * 用于包装查询返回的数据列表
 * @author HUYAO
 *
 * @param <T>
 */
public class PagerBean<T> {
	private boolean resultSuccess;
	
	private List<T> rows;
	
	private int page;
	
	private int pageSize;
	
	private int count;
	
	private Throwable exception;
	
	private Object[] reserve;
	
	public PagerBean() {
		page = 1;
		pageSize = Constants.pageSize;
		count = 0;
		
		exception = null;
	}

	public int getPage() {
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	public Throwable getException() {
		return exception;
	}

	public void setException(Throwable exception) {
		this.exception = exception;
	}
	
	public boolean hasException() {
		return exception != null;
	}

	public boolean hasReserve() {
		return reserve != null && reserve.length > 0;
	}
	
	public Object[] getReserve() {
		return reserve;
	}

	public void setReserve(Object[] reserve) {
		this.reserve = reserve;
	}
	
	public String toServiceString() {
		return "page:" + page + " pageSize:" + pageSize;
	}

	public List<T> getRows() {
		return rows;
	}

	public void setRows(List<T> rows) {
		this.rows = rows;
		this.resultSuccess = true;
	}

	public boolean isResultSuccess() {
		return resultSuccess;
	}

	public void setResultSuccess(boolean resultSuccess) {
		this.resultSuccess = resultSuccess;
	}
}
